// Global API configuration
var Api = new Restivus({
  useDefaultAuth: false,
  prettyJson: true,
  defaultHeaders: {
      'Content-Type': 'application/json'
  },
});
var no = 0;
// Maps to: /api/posts/:id
Api.addRoute('pay', {authRequired: false}, {
  get: function () {
    var wrapPingpp = Async.wrap(pingpp_server.charges, ['create', 'createUrlData']);
    var response = wrapPingpp.create({
          subject: "Your Subject",
          body: "Your Body",
          amount: 100,
          order_no: '' + (no ++),
          channel: "alipay",
          currency: "cny",
          client_ip: "127.0.0.1",
          app: {id: "app_rrjDmLOSCun9bPa9"},
    });
    console.log(response);
    return {
      status: 'success',
      charge: JSON.stringify(response),
      header: {'Access-Control-Allow-Origin:': '*'}
    };
  },
});